<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="Public/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="Public/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link href="Public/Flat/docs/assets/css/demo.css" rel="stylesheet">
	    <link rel="shortcut icon" href="Public/Flat/img/favicon.ico">
	    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
	    <!--[if lt IE 9]>
	      <script src="dist/js/vendor/html5shiv.js"></script>
	      <script src="dist/js/vendor/respond.min.js"></script>
	    <![endif]-->
	    <script src="./Public/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
	    <script type="text/javascript">
	    	$(function(){
	    		$(".fenlei").change(function(){
//	    			var tid = $(this).attr('tid');
//	    			if(tid==0){
//	    				alert('顶级分类不能添加商品');
//	    				return;
//	    			}
	    			var val = $(this).val();
	    			$.ajax({
	    				type:"post",
	    				url:"<?php echo U('endAjax')?>",
	    				data:{val:val},
	    				dataType:"json",
	    				success:function(data){
	    					var Shop_shux = "";
	    					var Shop_guig = "";
	    					$.each(data, function(k,v) {
								if(v.class == 1){
//	    						属性
									Shop_shux += '<label for="exampleInputEmail1">'+v.xname+'</label><select name="brand_pid" class="form-control"><option value="0">请选择</option>';
									$.each(v.xvalue, function(kk,vv) {
										Shop_shux += '<option value="">'+vv+'</option>';
									});
									Shop_shux += '</select>';
								}else{
									Shop_guig += '<label for="exampleInputEmail1">'+v.xname+'</label><select name="brand_pid" class="form-control"><option value="0">请选择</option>';
									$.each(v.xvalue, function(kk,vv) {
										Shop_guig += '<option value="">'+vv+'</option>';
									});
										Shop_guig += '</select><label for="exampleInputEmail1">附加价格</label><input id="exampleInputEmail1" class="form-control" type="text" placeholder="请输入分类排序" name="click">';
								}
	    					});
	    					$(".Shop_shux").html(Shop_shux);
	    					$(".Shop_guig").html(Shop_guig);
	    				}
	    			});
	    		return false;
	    		})
	    		})
	    </script>
	    
	</head>
	<body>
		<form method="post" enctype="multipart/form-data">
			<div class="alert alert-success">添加商品</div>
			<a href="javascript:;" class="btn btn-sm btn-primary">基本信息</a>
		<div class="form-group">
			<label for="exampleInputEmail1">所属分类</label>
			<select name="cate_cid" class="form-control fenlei">
				<?php foreach ($ShopCateData as $k=>$v){?>
				<option value="<?php echo $v['cid']?>" tid="<?php echo $v['cfid']?>"><?php echo $v['_cname']?></option>
				<?php }?>
			</select>
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">所属品牌</label>
			<select name="brand_pid" class="form-control">
				<?php foreach ($ShopBrandData as $k=>$v){?>
				<option value="<?php echo $v['pid']?>"><?php echo $v['pname']?></option>
				<?php }?>
			</select>
		</div>
		
		<div class="form-group">
			<label for="exampleInputEmail1">商品名称</label>
			<input id="exampleInputEmail1" class="form-control" type="text" placeholder="请输入商品名称" name="sname">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">单位</label>
			<input id="exampleInputEmail1" class="form-control" type="text" placeholder="件" name="unit">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">市场价</label>
			<input id="exampleInputEmail1" class="form-control" type="text" placeholder="请输入市场价" name="market">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">商城价</label>
			<input id="exampleInputEmail1" class="form-control" type="text" placeholder="请输入商城价" name="sale">
		</div>
		<div class="form-group">
			<label for="exampleInputEmail1">点击次数</label>
			<input id="exampleInputEmail1" class="form-control" type="text" placeholder="请输入分类排序" name="click">
		</div>
		<a href="javascript:;" class="btn btn-sm btn-primary">商品属性</a>
		<div class="Shop_shux">
			
		</div>
		<a href="javascript:;" class="btn btn-sm btn-primary">商品规格</a>
		<div class="Shop_guig">
			
		</div>
		<script src="./Public/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
		
			$(function(){
				$(".btn-warning").click(function(){
					$(".zuijia").prepend('<input id="exampleInputEmail1" type="file" name="thumb[]">')
				})
				$(".btn-danger").click(function(){
					$(".zuijia").empty();
				});
			})
		</script>
			<label for="exampleInputEmail1">列表图</label>
		<div class="form-group zuijia">
			<input id="exampleInputEmail1" type="file" name="thumb[]">
		</div>
			<a href="javascript:;" class="btn btn-sm btn-warning" style="color: red;">添加新图</a>
			<a href="javascript:;" class="btn btn-sm btn-danger">清空</a>	
		
		
	
		<button class="btn btn-primary btn-block" type="submit"> 确定 </button>
		</form>
	</body>
</html>
